@echo off

echo *************************** Start building process ***************************
echo.
echo.
echo ****************************************************************

set base_path=dist
echo current dir : %base_path%

set proname=littletool
echo project name : %proname%

set proname_full=littletool_full
echo project_full name : %proname_full%

echo.
echo ****************************************************************

cd %base_path%

if exist "%proname%" (

    if exist "%proname_full%" (

        ECHO Folder "%proname_full%" exists, well be deleted.

        RMDIR /S /Q "%proname_full%"
        IF ERRORLEVEL 1 (
            ECHO Failed to delete folder "%proname_full%".
            EXIT /B 1
        ) ELSE (
            ECHO Folder "%proname_full%" deleted successfully.
        )

    ) else (
        echo Folder "%proname_full%" not exists, well be created.
    )

    echo.
    echo ****************************************************************
    echo Start to create folder "%proname_full%".
    mkdir %proname_full%
    echo Success create folder "%proname_full%".

    echo.
    echo ****************************************************************
    echo Start to copy "%proname%" to "%proname_full%".
    xcopy "%proname%\*.*" "%proname_full%\" /E /I /C /Y
    echo Success copy "%proname%" to "%proname_full%".

    cd ../

    echo.
    echo ****************************************************************
    echo Start to copy "jdk" to "%proname_full%".
    xcopy "jdk\*.*" "%base_path%\%proname_full%\" /E /I /C /Y
    echo Success copy "jdk" to "%proname_full%".

    echo.
    echo ****************************************************************
    echo Start to copy "cmds" to "%proname_full%".
    xcopy "cmds\embed_java\*.*" "%base_path%\%proname_full%\" /E /I /C /Y
    echo Success copy "cmds" to "%proname_full%".

    echo.
    echo ****************************************************************
    echo Start to copy "cmds" to "%proname%".
    xcopy "cmds\local_java\*.*" "%base_path%\%proname%\" /E /I /C /Y
    echo Success copy "cmds" to "%proname%".

    echo.
    echo.
    echo *************************** Building process completed ***************************
    echo.
    echo.

)else (

    echo.
    echo ****************************************************************
    echo no %proname% found.

)

pause